home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / ScreenSavers / BackSpaceViews / SparseLifeView.BackModule / SparseLifeView.h < prev    next >
Text File  |  1995-06-12  |  3KB  |  104 lines

  1. #import <appkit/View.h>
  2.  
  3. #define ITERATIONS 20000/* max # of iterations before restarting */
  4. #define PANELTIME 333   /* ms delay between *panel* animation frames */
  5. #define DEEPEDGE 2      /* edge is this # squares beyond visible */
  6. #define MINCELLSIZE 2   /* Make sure cell size gets no smaller than... */
  7. #define MAXCELLSIZE 24  /* Make sure cell size gets no bigger than... */
  8. #define COLORS 24       /* Generations from youngest color to oldest color */
  9. #define SQUAREBLOCK 64  /* Number of squares of one color to draw at once */
  10. #define STATSIZE 1024   /* Recognizes all stasis periods up to this number */
  11. #define STATIVAL 128    /* Takes up to this long to recognize stasis */
  12. #ifdef DEEPEDGE
  13. #  define MAXCOLS (1280/MINCELLSIZE+2+2*DEEPEDGE)
  14. #  define MAXROWS (1024/MINCELLSIZE+2+2*DEEPEDGE)
  15. #else
  16. #  define MAXCOLS (1280/MINCELLSIZE+2) /* full screen of smallest cells (x) */
  17. #  define MAXROWS (1024/MINCELLSIZE+2) /* (y) */
  18. #endif
  19.  
  20. typedef struct _lifecell {
  21.     int next;
  22.     char neighbors;
  23.     char color;
  24. } lifecell;
  25.  
  26. @interface SparseLifeView:View
  27. {
  28.     lifecell Grid[MAXCOLS*MAXROWS];
  29.  
  30.     int ifirst;
  31.     int ncols, nrows;
  32.     int countDown;
  33.     int installedCountDown;
  34.     int cellSize;
  35.     int xoffset, yoffset;
  36.  
  37.     NXColor youngColor;
  38.     NXColor mediumColor;
  39.     NXColor oldColor;
  40.  
  41.     NXColor colorTable[COLORS];
  42.     int squareCount[COLORS];
  43.     NXRect squareBuffer[COLORS][SQUAREBLOCK];
  44.     
  45.     int stasis[STATSIZE];
  46.     int strack;
  47.     int spass;
  48.     int sindex;
  49.  
  50.     id sharedInspectorPanel;
  51.     id panelYoungColorWell;
  52.     id panelMediumColorWell;
  53.     id panelOldColorWell;
  54.     id panelRestartButton;
  55.     id panelStepButton;
  56.     id panelLifeView;
  57.     id panelCreditsView;
  58.     id panelSizeMatrix;
  59. }
  60.  
  61. - oneStep;
  62. - drawSquares;
  63. - putSquare:(int)x :(int)y Color:(int)color;
  64. - flushColor:(int)color;
  65. - flushSquares;
  66. - drawSelf:(const NXRect *)rects :(int)rectCount;
  67. - (const char *) windowTitle;
  68. - setupSquareBuffer;
  69. - initFrame:(const NXRect *)frameRect;
  70. - getLifeDefaults;
  71. - sizeTo:(NXCoord)width :(NXCoord)height;
  72. - initLife;
  73. - clearLife;
  74. - checkStasis:(int)checksum;
  75.  
  76. - computeColors;
  77. - updateViews;
  78.  
  79. - inspector:sender;
  80. - inspectorInstalled;
  81. - takeYoungColorFrom:sender;
  82. - takeMediumColorFrom:sender;
  83. - takeOldColorFrom:sender;
  84. - doSizeMatrix:sender;
  85. - doSingleStep:sender;
  86. - doRestart:sender;
  87.  
  88. - showCredits:sender;
  89. - hideCredits:sender;
  90.  
  91. - doShowCredits:sender;
  92. - doHideCredits:sender;
  93.  
  94. @end
  95.  
  96. @interface StaticSparseLifeView:SparseLifeView
  97. {
  98. }
  99. - setYoungColor:(NXColor)yc MediumColor:(NXColor)mc OldColor:(NXColor)oc;
  100. - setLifeCellSize:(int)cs;
  101.  
  102. @end
  103.  
  104.